Skip to content

acli: fix Windows TUI (run_command, wheel scroll) + bench-driven fixes - #188

Merged
lzsweb merged 10 commits into
mainfrom
release/agentic-cli-3
Sep 4, 2026
Merged

acli: fix Windows TUI (run_command, wheel scroll) + bench-driven fixes#188
lzsweb merged 10 commits into
mainfrom
release/agentic-cli-3

Conversation

@lzsweb

@lzsweb lzsweb commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

Two user-facing Windows TUI repairs, plus the agent-side changes that came out of running the hard task set of terminal-bench, plus the v0.6.4 sync.

Windows TUI: the shell tool was unusable, and scrolling was broken

  • run_command failed on every single call inside the TUI, with AttributeError: '_PrintCapture' object has no attribute 'encoding'. The decode path read sys.stdout.encoding, but textual replaces sys.stdout with a capture object that has no .encoding — and the read was guarded by an IS_WINDOWS branch, so POSIX short-circuited and never hit it. The command actually ran; only the decoding blew up, and the error surfaced as a tool failure, so the model retried the identical call until the turn died. The console encoding is now resolved once at import, before the TUI takes over stdout.
  • The same block corrupted commands containing double quotes: powershell -Command "<cmd>" went through create_subprocess_shell, i.e. through cmd.exe first, so the command was parsed twice. It is now a single argv element via create_subprocess_exec, prefers pwsh (PowerShell 7) over the legacy powershell.exe, and adds -NoProfile — profile scripts were costing hundreds of milliseconds on every call.
  • The mouse wheel moved the input box instead of scrolling the output. Mouse capture was defaulted off on Windows, so the terminal never learned the app wanted mouse events and translated the wheel into arrow keys: those hit CommandInput's history, so wheeling up walked backwards through previous inputs while the output area never moved, and wheeling down walked back to the draft. Alternatively the console host scrolled its own buffer and dragged the whole screen. Capture is now on everywhere; tui_mouse = false stays as the escape hatch for terminal-native selection (Alt/Option-drag to copy).

From the hard-task bench work

  • Post-change verification rule + plan wiring — on receiving a requirement the agent must analyze, split the work, write a plan, set up verification (e.g. unit tests), and only then start editing files or running commands. Motivated by tasks where it declared itself done without ever executing a test.
  • Budget-aware nudge + retry hardening — fewer turns lost to transient provider failures.
  • oneshot --max-turns / --protocol overrides — callers driving acli non-interactively need to set the turn budget per task; the flags were previously ignored.
  • Default model → qwen3.8-max across config, tongyi provider, SDK, embedded UI, setup preset and both examples.

Two generalizable agent defects surfaced while reading the failures, worth noting even though neither is fixed here:

  • A task validated its own output with jsonschema.validate, passed its own check, and still got the result wrong — the schema constrained a field to "an object" but said nothing about the key names, which the grader indexes differently. Schema-valid is not spec-correct; literal output-contract details (key names, units) have to be checked against the task text.
  • A turn burned on /bin/sh: 1: time: not found, because time is a shell builtin and is unavailable under sh -c.

The other observation is that these tasks are limited by per-turn model latency rather than by the turn budget: wall clock is dominated by waiting on the model between tool calls, and raising the turn ceiling changed no outcome. Per-call token usage is not captured yet, so "prompt too large" cannot be distinguished from "model slow" — that instrumentation is the prerequisite for optimizing further.

Also in this sync

  • Executor confirm_mode = dangerous — only risky operations prompt for confirmation.
  • TUI markdown table rendering; input draft restored around confirm prompts.
  • New memory reflection module.

Test plan

  • Upstream acli unit suite: 17 pre-existing failures (test_executor, test_governance_edge), no new ones.
  • 7 new tests cover the Windows run_command path, reproduced on POSIX by forcing IS_WINDOWS and installing textual's real _PrintCapture — including the verbatim AttributeError the field report showed. 3 new tests pin the tui_mouse default and its config escape hatch.
  • Mirrored tree passes black and the dashscope.acli import check run by scripts/sync_acli.sh.
  • Needs a real Windows box: under PowerShell 7 in Windows Terminal, wheel-scroll the output (output must scroll, input box must not move) and run a command containing double quotes, e.g. python -c "import os; print(os.getcwd())".
  • Confirm legacy conhost does not regress — that is where mouse capture was originally reported as crash-prone; tui_mouse = false reverts it.

zhansheng.lzs added 9 commits September 1, 2026 16:28
Sync agenticCLI v0.6.3 into dashscope/acli:
- stagnation tracker with read-only hard cap for oneshot runs
- auto_approve config + ACLI_AUTO_APPROVE env override
- oneshot mode flag wired into the CLI runner
- convergence nudge becomes budget-aware for autonomous runs
- HardenedProvider: capped exponential backoff (3 retries, 4s base,
  16s cap) to survive transient model-API failures in long runs
…t for confirmation

- New config option confirm_mode: "dangerous" (default) | "all"
- CONFIRM-level tools (run_command, write_file, ...) auto-pass in dangerous mode
- Read-only commands (grep/ls/cat/...) already skip prompts via is_safe_readonly
- Policy deny rules still take precedence over auto-pass
- DANGEROUS tools (delete_file, delete_directory) always prompt
…ring

Mirrors upstream 4562c7d and picks up the 0.6.4 version bump (SDK
version stays 1.27.4, which is still unreleased on this branch).

Coding tasks were ending without a single test run because the prompt
asked for it: rule 3 said to edit code "without stating a plan first",
the Concise bullet banned "test this / verify" as filler, and another
bullet forbade reporting what had just been done.

- rule 18: run the tests covering the change, or add a focused test when
  nothing covers it, and report command + pass/fail
- rule 4: multi-step work uses create_plan/complete_step, already
  registered and echoed as "## Current plan" but never mentioned before

Tree verified byte-identical to upstream src/acli after the import
rewrite; black passed and every dashscope.acli module imports.
…lient header

Mirrors agenticCLI 999db69 and 72ecc69:

- `-c` returned from main() before the --protocol/--max-turns overrides were
  applied, so oneshot always ran with the config default of 50 turns. Every
  terminal-bench run that asked for 150 was really capped at 50.
- TongyiProvider now sends acli/<version>[/<module>] in a single
  x-dashscope-sdk-client header instead of splitting the version into
  x-dashscope-sdk-version.
Mirrors bc7caee: qwen3.8-max becomes the factory default in Config,
TongyiProvider, run_interactive/embedded.run and the Alibaba/Bailian setup
preset. Also re-vendors examples from agenticCLI-examples (67f2249) so
basic-chat and dashscope-sdk-expert stop overriding that default with
qwen3.7-max / qwen3.7-plus.
sys.stdout.encoding was read while decoding subprocess output, but the
TUI replaces sys.stdout with textual's capture object, which has no
.encoding, so every command failed with AttributeError. The encoding is
now resolved at import. Also passes the command to PowerShell as its own
argv element (no cmd.exe re-quoting), prefers pwsh, and adds -NoProfile.
With capture off the terminal never learns the app wants mouse events, so
Windows Terminal and conhost translate the wheel into arrow keys or
scroll their own buffer: the input box moved through its history, or the
whole screen dragged, while the output area never scrolled.
@lzsweb lzsweb changed the title acli sync: Windows TUI fixes + qwen3.8-max default acli: hard-10 bench 2/10 → 5/10 (agent hardening + qwen3.8-max) Sep 4, 2026
@lzsweb lzsweb changed the title acli: hard-10 bench 2/10 → 5/10 (agent hardening + qwen3.8-max) acli: hard-task bench fixes — self-verification, retries, Windows TUI Sep 4, 2026
@lzsweb lzsweb changed the title acli: hard-task bench fixes — self-verification, retries, Windows TUI acli: fix Windows TUI (run_command, wheel scroll) + bench-driven fixes Sep 4, 2026
Cover the four core components:
- is_readonly_tool_call: 67 cases (known tools, shell commands, pipes,
  redirects, container subcmds, env prefix, edge cases)
- ReflectionTracker: 11 cases (threshold, reset, hints, lessons)
- StagnationTracker: 10 cases (streak, hard cap, mixed sequences)
- convergence_hint: 12 cases (soft/hard boundaries, custom ratios,
  remaining calculation, disable conditions)
@lzsweb
lzsweb merged commit 39c16c7 into main Sep 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant